﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace fap
{
    public static class ExtentionMethod
    {

        public static object GetReflectionField<T1>(this T1 node, string field)
        {
            Type t = node.GetType();
            var prop = t.GetProperty(field);
            if (prop != null)
            {
                var val = prop.GetValue(node);
                return val;
            }
            return null;
        }

        public static int Count(this IEnumerable source)
        {
            if (source == null)
                throw new ArgumentNullException();

            ICollection collection = source as ICollection;
            if (collection != null)
                return collection.Count;
            int num = 0;
            var enumerator = source.GetEnumerator();
            while (enumerator.MoveNext())
                num++;
            return num;
        }
    }
}
